package com.demo.gateway.service;

import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
/**
 * @author: demo
 * @date: 2020年6月18日
 * @Document :  实现路由刷新
 */
public abstract class AbstractDynamicGatewayRoute implements IGateWayRoute, ApplicationEventPublisherAware {
	
	public ApplicationEventPublisher applicationEventPublisher;
	
	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
		this.applicationEventPublisher = applicationEventPublisher;
	}

	@Override
	public void refreshRoute() {
		  this.applicationEventPublisher.publishEvent(new RefreshRoutesEvent(this));
	}
}
